﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Bitis_KeToanThue_Pro_DungChung.Common;

namespace Bitis_KeToanThue_Pro_DanhMuc.AccessDatabase
{
    class DanhMucTaiSan
    {
        AccessData ac = new AccessData(1);
        public int them(string ten,string dvt,int ng_thuc_gs,string tk,string donvi)
        {
            SqlParameter[] arrpara = new SqlParameter[5];
            arrpara[0] = new SqlParameter("TenTSCD", SqlDbType.NVarChar);
            arrpara[1] = new SqlParameter("DVT", SqlDbType.NVarChar);
            arrpara[2] = new SqlParameter("ng_thuc_gs", SqlDbType.Int);
            arrpara[3] = new SqlParameter("SoTK", SqlDbType.Char);
            arrpara[4] = new SqlParameter("MaDV", SqlDbType.Char);

            arrpara[0].Value = ten;
            arrpara[1].Value = dvt;
            arrpara[2].Value = ng_thuc_gs;
            arrpara[3].Value = tk;
            arrpara[4].Value = donvi;

            DataTable dt = ac.ftblDocDuLieuSP("sp_themtscd", arrpara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public int xoa(int matscd)
        {
            SqlParameter[] arrpara = new SqlParameter[1];
            arrpara[0] = new SqlParameter("MaTSCD", SqlDbType.Int);
            arrpara[0].Value = matscd;
            DataTable dt = ac.ftblDocDuLieuSP("sp_xoatscd", arrpara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public int sua(int matscd,string ten, string dvt, int ng_thuc_gs, string tk, string donvi)
        {
            SqlParameter[] arrpara = new SqlParameter[6];
            arrpara[0] = new SqlParameter("MaTSCD", SqlDbType.Int);
            arrpara[1] = new SqlParameter("TenTSCD", SqlDbType.NVarChar);
            arrpara[2] = new SqlParameter("DVT", SqlDbType.NVarChar);
            arrpara[3] = new SqlParameter("ng_thuc_gs", SqlDbType.Int);
            arrpara[4] = new SqlParameter("SoTK", SqlDbType.Char);
            arrpara[5] = new SqlParameter("MaDV", SqlDbType.Char);

            arrpara[0].Value = matscd;
            arrpara[1].Value = ten;
            arrpara[2].Value = dvt;
            arrpara[3].Value = ng_thuc_gs;
            arrpara[4].Value = tk;
            arrpara[5].Value = donvi;

            DataTable dt = ac.ftblDocDuLieuSP("sp_suatscd", arrpara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public DataTable load_grid()
        {
            return ac.ftblDocDuLieuSP("sp_loadtscd", null);
        }
        public DataTable load_combodv()
        {
            return ac.ftblDocDuLieuSP("sp_loadcombodv", null);
        }
        public DataTable load_combotk()
        {
            return ac.ftblDocDuLieuSP("sp_loadcombotk", null);
        }
    }
}
